// let str="abacdaaa";
// let arr=str.split("a");
// console.log(arr);

// let num=parseInt("19934318");
// let count=0;

// while(num>0){
//     if(num%2){
//         count++;
//     }
//     num=Math.floor(num/2);
// }
// console.log(count);
// while(sourceNum >= 1){
//     if(1 == sourceNum % 2){
//         resultCount ++;   
//     }
//     resultStr = (sourceNum % 2) + resultStr;
//     sourceNum = (sourceNum / 2).toString().split('.')[0];
// }
// console.log(resultCount);
//console.log(parseInt(num).toString(2).split(1).length-1);
let re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u;

let rs='2015-01-02'.replace(re, '$<day>/$<month>/$<year>');
console.log(rs);
let date='2015-01-02';
let str=date.split('-');
let [year,month,day]=str;
console.log(year,month,day);

//格式化日期
//1.正则方式
function RegexFomat(date=""){
    const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u;
    return date.replace(re, '$<day>/$<month>/$<year>');
}
//把字符串里的内容格式化成变量并且操作
function formatDate1(){

}
{
    //传一个字符串日期
    let now=new Date("2015-01-02");
    let [year,month,day]=[now.getFullYear(),now.getMonth()+1,now.getDate()]
    console.log('now',now);
    console.log('year',year);
    console.log('month',month);
    console.log('day',day);
    console.log(now.getDay());//星期几
    console.log(now.getHours());
    console.log(now.getMinutes());
    console.log(now.getSeconds());
    console.log(now.getMilliseconds());
}
